setwd("D:\\杨熊冰\\R语言\\实验报告\\data for class3")

library(openxlsx)
ADdata1<-read.table("ADdata1.txt")#把ID信息放到行名
ADdata2<-read.csv("ADdata2.csv",row.names = 1) #把ID信息放到行名
ADdata3<-read.xlsx("ADdata3.xlsx",rowNames = TRUE) #把ID信息放到行名
ADdata4<-read.table("ADdata4.txt") #把ID信息放到行名
ADdata5<-merge(ADdata1,ADdata2,by = 0) #1,2合并 根据行名合并写法1
ADdata6<-merge(ADdata3,ADdata4, by = "row.names") #3,4合并 根据行名合并写法2
ADdata <- merge(ADdata5,ADdata6) #最终合并
rownames(ADdata) <- ADdata$Row.names #第一列放回到行名
ADdata <- ADdata[,-1] #去掉第一列
write.csv(ADdata,file="ADdata.csv") #保存为csv文件
write.xlsx(ADdata,file="ADdata.xlsx") #保存为xlsx文件
write.table(ADdata,file="ADdata.txt") #保存为txt文件                                                                   

